<!DOCTYPE html>
<html>
<head>
	{$view->headTitle()}
	{$view->headMeta()}
	{$view->JQuery()}
	<link rel="stylesheet" type="text/css" media="screen" href="{$view->baseUrl()}/ui/css/control.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="{$view->baseUrl()}/ui/phorm/phorm.css" />
	<script type="text/javascript" src="{$view->baseUrl()}/ui/js/jquery.layout.min.js"></script>
	<script type="text/javascript" src="{$view->baseUrl()}/ui/phorm/phorm.js"></script>
	<script type="text/javascript">
		var Layout;
		var trees = {}; // Массив деревьев-меню
		
		$(document).ready(function(){
			{if $params.controller=='index' && $params.action=='index'}
				Layout = $('body').layout({ 
					applyDefaultStyles: true,
					west__size: 300,
					west__spacing_open: 4,
					north__spacing_open: 4
				});
				$('.ui-layout-west .accordion').accordion({ fillSpace: true });
				trees.categories = $('.ui-layout-west .tree.categories').phormTree();
				trees.mvc = $('.ui-layout-west .tree.mvc').phormTree();
			{/if}
			phorm_ui_changeState();
			phorm_ui_hideWarnings();
				
			$('form .zend_form fieldset legend').css('cursor','pointer').attr('title','{$translate->_("Свернуть/развернуть")}').click(function(){
				$(this).next('dl').toggle();
			});
			
			$('body').on('click','a[href=#]',function(){
				return false;
			});
				
		});
	</script>
	{if $params.controller=='index' && $params.action=='index'}
		<style>
			.ui-layout-north,
			.ui-layout-center,
			.ui-layout-east,
			.ui-layout-west { padding: 0 !important; margin: 0 !important; overflow: hidden !important; border: none !important; }
			.ui-layout-west .ui-accordion-header.ui-corner-all { border-radius: 0 !important; }
			.ui-layout-west .ui-accordion-content.ui-corner-bottom { border-radius: 0 !important; }
			.ui-layout-west .ui-accordion-header.ui-corner-top { border-radius: 0 !important; }
			.ui-layout-west ul { padding: 0; margin: 0; list-style: none; }
		</style>
		<base target="CenterFrame" /> <!-- Не работает для ифреймов? -->
	{/if}
</head>
	<body class="ui-widget">

	{if $params.controller=='index' && $params.action=='index'}
	
		<div class="ui-layout-north">
			<div class="ui-widget-content header">
				<h2>Система управления сайтом Phorm.CMS <span><a href="/">Перейти на основной сайт</a></span></h2>
				<div id="switcher"></div>
				{if $UserData.userid>0}
					<div>
						Пользователь: {$UserData.username}<br />
						<a href="{$view->siteUrl()}/users/signout/">{_('Выход')}</a>
						{if $Acl.mvc.default.users.profile} &nbsp; <a href="{$view->siteUrl()}/users/profile/">{$translate->_('Ваш профиль')}</a>{/if}
					</div>
				{/if}
			</div>
		</div>

		<div class="ui-layout-west">
			<div class="accordion">
				
				<h3><a>{$translate->_('Разделы сайта')}</a></h3>
				<div class="tree categories">{$CategoriesTree}</div>
				
				<h3><a>{$translate->_('Материалы сайта')}</a></h3>
				<div class="resources">
					<ul>
						{foreach from=$ModulesList item=data}
							<li><a target="CenterFrame" href="{$view->siteUrl()}/control/resource/index/moduleid/{$data.moduleid}/" title="{$translate->_('Список')} {$data.genetivename}">{$data.modulename}</a></li>
						{/foreach}
					</ul>
					<p><a target="CenterFrame" href="{$view->siteUrl()}/control/resource/addmodule/" class="ui-button ui-button-text-icons ui-state-default ui-corner-all"><span class="ui-icon ui-icon-plusthick"></span><span class="ui-button-text">Создать новый тип материала</span></a></p>
				</div>
				
				<h3><a>{$translate->_('Модули')}</a></h3>
				<div class="modules">
					<ul>
						{*<li><a target="CenterFrame" href="{$view->siteUrl()}/control/media/">{$translate->_('Медиа-библиотека')}</a></li>*}
						{if $Acl.mvc.control.structures}
							<li><a target="CenterFrame" href="{$view->siteUrl()}/control/structures/">{$translate->_('Структуры данных')}</a></li>
						{/if}
						{if $Acl.mvc.control.browser.files}
							<li><a target="CenterFrame" href="{$view->siteUrl()}/control/browser/files/">{$translate->_('Файловый менеджер')}</a></li>
						{/if}
						{if $Acl.mvc.control.dictionaries}
							<li><a target="CenterFrame" href="{$view->siteUrl()}/control/dictionaries/">{$translate->_('Справочники')}</a></li>
						{/if}
						{if $Acl.mvc.control.store}
							<li><a target="CenterFrame" href="{$view->siteUrl()}/control/store/">{$translate->_('Интернет-магазин')}</a></li>
						{/if}
						<li>{$translate->_('Комментарии')}</li>
						<li>{$translate->_('XML-меню')}</li>
					</ul>
				</div>
				
				<h3><a>{$translate->_('MVC-ресурсы (отдельные страницы)')}</a></h3>
				<div>
					<div class="tree mvc">{$MvcTree}</div>
					
					<p>
						{if $Acl.mvc.control.mvc.acl}
							<a target="CenterFrame" href="{$view->siteUrl()}/control/mvc/acl/" class="ui-button ui-button-text-icons ui-state-default ui-corner-all"><span class="ui-icon ui-icon-suitcase"></span><span class="ui-button-text">{$translate->_('Права доступа')}</span></a>
						{/if}
					</p>
				</div>
				
				{if $Acl.mvc.control.users}
					<h3><a>{$translate->_('Пользователи')}</a></h3>
					<div class="users">
						<h4>{$translate->_('Пользователи')}</h4>
						<p class="ui-buttonset">
							{if $Acl.mvc.control.users.index}
								<a target="CenterFrame" href="{$view->siteUrl()}/control/users/" class="ui-button ui-button-text-icons ui-state-default ui-corner-all"><span class="ui-icon ui-icon-document"></span><span class="ui-button-text">{$translate->_('Список')}</span></a>
							{/if}
							{if $Acl.mvc.control.users.add}
								<a target="CenterFrame" href="{$view->siteUrl()}/control/users/add/" class="ui-button ui-button-text-icons ui-state-default ui-corner-all"><span class="ui-icon ui-icon-plusthick"></span><span class="ui-button-text">{$translate->_('Добавить')}</span></a>
							{/if}
						</p>
						<h4>{$translate->_('Группы пользователей')}</h4>
						<p class="ui-buttonset">
							{if $Acl.mvc.control.users.roles}
								<a target="CenterFrame" href="{$view->siteUrl()}/control/users/roles/" class="ui-button ui-button-text-icons ui-state-default ui-corner-all"><span class="ui-icon ui-icon-document"></span><span class="ui-button-text">{$translate->_('Список')}</span></a>
							{/if}
							{if $Acl.mvc.control.users.roleadd}
								<a target="CenterFrame" href="{$view->siteUrl()}/control/users/roleadd/" class="ui-button ui-button-text-icons ui-state-default ui-corner-all"><span class="ui-icon ui-icon-plusthick"></span><span class="ui-button-text">{$translate->_('Добавить')}</span></a>
							{/if}
						</p>
					</div>
				{/if}
				
				{if $Acl.mvc.control.widgets}
					<h3><a>{$translate->_('Внешний вид')}</a></h3>
					<div class="widgets">
						<p class="ui-buttonset">
							{if $Acl.mvc.control.widgets.index}
								<a target="CenterFrame" href="{$view->siteUrl()}/control/widgets/" class="ui-button ui-button-text-icons ui-state-default ui-corner-all"><span class="ui-icon ui-icon-document"></span><span class="ui-button-text">{$translate->_('Список')}</span></a>
							{/if}
							{if $Acl.mvc.control.widgets.add}
								<a target="CenterFrame" href="{$view->siteUrl()}/control/widgets/add/" class="ui-button ui-button-text-icons ui-state-default ui-corner-all"><span class="ui-icon ui-icon-plusthick"></span><span class="ui-button-text">{$translate->_('Добавить')}</span></a>
							{/if}
						</p>
					</div>
				{/if}
				
			</div>
		</div>
		
		<iframe class="ui-layout-center" id="CenterFrame" name="CenterFrame" src="{$view->siteUrl()}/control/index/extend/"></iframe>
		
	{else}
	
		{include file='control/helpers/functions.tpl'}

		<h1 class="ui-widget-header">{$Header}</h1>
		
		<div class="allcontent ui-widget-content">
			{call name="ErrorsMessages"}
			{$MvcInfo.resourcetxt}
			{if $Layouts.center}{""|implode:$Layouts.center}{/if}
			<div class="clear"></div>
		</div>
		
		{if $cnf.resources.db.params.profiler}
			<p align="center">Всего выполнено {$SqlQueries} запросов за {$SqlTotal} сек.</p>
		{/if}
	
	{/if}
		
	</body>
</html>

